package com.mt.reader;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;

import com.x.service.api.BookApi;
import com.x.service.entity.BookDetail;
import com.x.xiaoshuo.ui.read.ReadActivity;

import okhttp3.OkHttpClient;
import rx.functions.Action1;
import rx.schedulers.Schedulers;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        findViewById(R.id.button).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                BookApi.getInstance(new OkHttpClient()).getBookDetial("555abb2d91d0eb814e5db04f")
                        .subscribeOn(Schedulers.io())
                        .subscribe(new Action1<BookDetail>() {
                            @Override
                            public void call(BookDetail bookDetail) {
                                ReadActivity.startActivity(MainActivity.this, bookDetail);
                            }
                        }, new Action1<Throwable>() {
                            @Override
                            public void call(Throwable throwable) {

                            }
                        });
            }
        });
    }
}
